<?php

namespace app\queue\single;

use app\model\SysOperateLog;
use core\constants\QueueKey;
use support\Log;
use Throwable;
use Webman\RedisQueue\Consumer;

class OperationLog implements Consumer
{
    // 要消费的队列名
    public $queue = QueueKey::OPERATION_LOG;

    // 连接名，对应 plugin/webman/redis-queue/redis.php 里的连接`
    public $connection = 'default';

    // 消费
    public function consume($data)
    {
        try {
            SysOperateLog::insert($data);
        } catch (Throwable $exception) {
            Log::error(OperationLog::class . " insert error " . $exception->getMessage());
        }
    }
}
